home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / vol7n3.arc / PP703.ARC / TRY.C < prev    next >
C/C++ Source or Header  |  1988-01-08  |  940b  |  31 lines

  1. /*
  2.         TRY.C   --- demonstrates binding of TRYATOI.ASM
  3.                     and ATOI.ASM to a C program
  4.         Ray Duncan, October 1987
  5. */
  6.  
  7. #include <stdio.h>
  8.  
  9. int TRYATOI(const char *);      /* declare function */
  10.  
  11. main(int argc,char *argv[])
  12. {   char buff[80];              /* keyboard input buffer */
  13.     int ivar;                   /* an integer variable */
  14.  
  15.     while(1)
  16.     {                           /* display prompt */
  17.        printf("\n\nEnter a number (Q to quit):  ");
  18.  
  19.        gets(buff);              /* read string from keyboard */
  20.         
  21.                                 /* exit if 'Q' or 'q' entered */
  22.        if( buff[0] == 'Q' || buff[0] == 'q') break;     
  23.  
  24.                                 /* call MASM binding */
  25.        ivar=TRYATOI(buff);      /* string to int */
  26.  
  27.                                 /* now display result */
  28.        printf("\n\t TRYATOI(your entry) = %d ", ivar);
  29.    }
  30. }
  31.